<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="layout" content="main"/>
    <g:set var="entityName" value="${message(code: 'workWeek.label', default: 'WorkWeek')}"/>
    <title><g:message code="default.create.label" args="[entityName]"/></title>
</head>
<body>
<div class="body">
    <h1><g:message code="default.create.label" args="[entityName]"/></h1>
    <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
    </g:if>
    <g:hasErrors bean="${workWeekInstance}">
        <div class="errors">
            <g:renderErrors bean="${workWeekInstance}" as="list"/>
        </div>
    </g:hasErrors>
    <g:form action="save">
        <g:hiddenField name="contractorId" value="${params.contractorId}"/>
        <div class="dialog">
            <table>
                <tbody>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="startDate"><g:message code="startDate" default="Start of week"/></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: workWeekInstance, field: 'startDate', 'errors')}">
                        <joda:datePicker name="startDate" value='${workWeekInstance.startDate}' noSelection="['':'']"/>
                    </td>
                </tr>

                <g:each var="dayOfWeek" status="status" in="${['monday', 'tuesday', 'wednesday', 'thursday', 'friday']}">
                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="${dayOfWeek}"><g:message code="workWeek.${dayOfWeek}.label" default="${dayOfWeek}"/></label>
                        </td>
                        <td><g:textField name="${dayOfWeek}.numOfHours" value="${fieldValue(bean: workWeekInstance."${dayOfWeek}", field: 'numOfHours')}"/></td>
                    </tr>
                </g:each>

                </tbody>
            </table>
        </div>
        <div class="buttons">
            <span class="button"><g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}"/></span>
        </div>
    </g:form>
</div>
</body>
</html>
